package com.pda.gongpin.presenter;

import com.pda.gongpin.bean.HandingOutStaticsBean;
import com.pda.gongpin.bean.request.DeliveryNoRequest;
import com.pda.gongpin.contract.HandingOutStaticsContract;
import com.pda.gongpin.net.NetUtils;
import com.wangshen.base.net.bean.BaseAppEntity;
import com.wangshen.base.ui.mvp.base.presenter.BasePresenter;

import java.util.List;

import io.reactivex.functions.Consumer;

public class HandingOutStaticsPresenter extends BasePresenter<HandingOutStaticsContract .View> implements HandingOutStaticsContract.Presenter{
    @Override
    public void getManualShipmentsStatistics(DeliveryNoRequest body) {
        NetUtils.geApi().getManualShipmentsStatistics(body)
                .compose(this.handleEverythingResult())
                .subscribe(new Consumer<BaseAppEntity<List<HandingOutStaticsBean>>>() {
                    @Override
                    public void accept(BaseAppEntity<List<HandingOutStaticsBean>> listBaseAppEntity) throws Exception {
                        getView().setList(listBaseAppEntity.getData());
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        getView().showMessage(throwable.getMessage());
                    }
                });
    }
}
